﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="AddAccountCommand.cs" company="Concept Architecture">
//   (c) 2010 Muhammad Umer Farooq
// </copyright>
// <summary>
//   Defines the <seealso cref="AddAccountCommand" /> type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Hisaab.Client.Modules.Core.Account.Commands
{
    using System;
    using System.Windows.Input;
    using Common;
    using Microsoft.Practices.Prism.Regions;
    using Microsoft.Practices.ServiceLocation;

    /// <summary>
    /// Defines the <seealso cref="AddAccountCommand"/> type.
    /// </summary>
    public class AddAccountCommand : ICommand
    {
        /// <summary>
        /// Actions to take when CanExecute changes.
        /// </summary>
        public event EventHandler CanExecuteChanged
        {
            add { CommandManager.RequerySuggested += value; }
            remove { CommandManager.RequerySuggested -= value; }
        }

        /// <summary>
        /// Defines the method to be called when the command is invoked.
        /// </summary>
        /// <param name="parameter">Data used by the command.  If the command does not require data to be passed, this object can be set to null.</param>
        public void Execute(object parameter)
        {
            // Initialize
            var regionManager = ServiceLocator.Current.GetInstance<IRegionManager>();

            // Show Workspace
            var dashboardWorkspace = new Uri(AccountModule.AccountEditor, UriKind.Relative);
            regionManager.RequestNavigate(Regions.SecondaryRegion, dashboardWorkspace);
        }

        /// <summary>
        /// Defines the method that determines whether the ShowModuleAViewCommand is enabled.
        /// </summary>
        /// <param name="parameter">Data used by the command.  If the command does not require data to be passed, this object can be set to null.</param>
        /// <returns>
        /// true if this command can be executed; otherwise, false.
        /// </returns>
        public bool CanExecute(object parameter)
        {
            return true;
        }
    }
}